
public class Test {

    public static void main(String[] args){
        long b = 10L;
        int i =3;
        i += b;          //不会报错，自动强制类型转化
        System.out.println(i);
        //float f = 10.2;
        //会报错，不加f会默认为double类型，会报错
        float f = 10.2f;
    }


   public static void main4(String[] args){
        short a = 128;
        byte b =(byte)a;
        System.out.println(b);
    }
    public static void main3(String[] args){
        byte a = 10;
        byte b = 10;
        byte c = (byte)(a+b);  //Java计算时会将小于4字节的数据转换成4字节（整型提升），因此需要一次强制类型转换
    }

    public static void main2(String[] args){
        int a = 10;
        //错误写法，应当强制类型转换
        //short c = a;
        short d = (short) a;


        int b = 20;
        System.out.println(a == b);
        System.out.println(a != b);
        System.out.println(a <= b);
        System.out.println(a >= b);

    }


}
